$(function() {
	// 查询电影
	var data = {
		isHot : 1
	};
	$.ajax({
				type : 'POST',
				url : '/movie.front/movieInfo/getMovieInfoList',
				dataType : 'json',
				contentType : 'application/json',
				data : JSON.stringify(data),
				success : function(data) {
					var arry = data.result;
					for (var i = 0; i < arry.length; i++) {
						var url = 'http://localhost:8080/'
	var html = '<div id="pictureInfo" class="col-md-3 gallery-grid"> <a class="lianjie" href="single.html?id='+ arry[i].id+'">'
						    +'<img class="img-responsive" style="width:180px;height:200px" alt=""  src='
								+ url
								+ arry[i].moviePicture
								+ '><p style="padding-left:68px;color:#715525"><font size="3">'
								+ arry[i].movieName + '</font></p></a></div>';

						$('#gallery-pictures').append(html);
					}

				},
				error : function(data) {
					alert("网络异常");
				}
			});
	
	$.ajax({
		  type:'POST',
		  url:'/movie.front/movieInfo/getCountMovieInfo',
		  dataType:'json',
		  contentType:'application/json',
		  data:JSON.stringify(data),
		  success:function(data){
			  var count = data.result;
			  var html = '<font size="5px" color="#f07818">正在热映('+count+'部)</font>';
			  $('.well-received').append(html);
		  }
	});
	var data = {
		isHot : 2
	}

   $('#all-movies').click(function(){
	   window.location.href="products.html"; 
   });
	$('#myCart').click(function(){
		$.ajax({
			  type:'POST',
			  url:'/movie.front/orderController/getOrderListsByUserId',
			  dataType:'json',
			  contentType:'application/json',
			  data:JSON.stringify(data),
			  success:function(data){
				
				 if(data.result[0].statusCode!=null){
					  alert(data.result[0].statusCode);
					 window.location.href="account.html";
				 }else{
					 $('#myorders-table').empty();
					 var data =data.result;
					 for(var i=0;i<data.length;i++){
						 var html='';
						 html = html+'<tr><td  align="center">'+data[i].orderName+'</td><td  align="center">'+data[i].orderPrice+'元</td><td  align="center">'+data[i].orderTime+'</td></tr>';
						 $('#myorders-table').append(html);
					 }
				 }
			  }
		});
	});
});
